import React, {useEffect} from 'react';

// 引入柱状图
import 'echarts/lib/chart/bar';
// 引入提示框和标题组件
import 'echarts/lib/component/tooltip';
import 'echarts/lib/component/title';
import {Card} from "antd";
import {useRequest} from "@@/plugin-request/request";
import {statisticsByType} from "@/pages/demand/DemandStatistics/service";

const DemandStatistics: React.FC<{}> = (props) => {

  /**
   * 获取需求类型统计
   */
  useRequest(() => statisticsByType(), {
    onSuccess: (result, params) => {
      // let echarts = require('echarts');
      // // 基于准备好的dom，初始化echarts实例
      // let myChart = echarts.init(document.getElementById('main'));
      // // 绘制图表
      // let total;
      // result.forEach((n:any)=>{
      //   if(n.name === "总计"){
      //     total = n.value;
      //     return;
      //   }
      // })
      // myChart.setOption(getPieOption({title:"需求类型分布", subTitle:"总计：" + total, data:deleteOfJsonArrays("name", "总计", result)}));
    }
  })

  useEffect(()=>{

  },[])

  return (
    <Card>
      <div style={{width:"50%", height:"400px"}} id={"main"}></div>
    </Card>
  );
}

export default DemandStatistics;
